package cn.ywsj.ywsjmidtier.controller;

import cn.ywsj.ywsjmidtier.entity.VO.UserInfoQueryVo;
import cn.ywsj.ywsjmidtier.entity.VO.UserInfoVo;
import cn.ywsj.ywsjmidtier.service.LoginFeign;
import cn.ywsj.ywsjmidtier.utils.JsonObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @ClassName : WechatGoodsReceiptAddressController
 * @Author : Lenovo
 * @Date: 2021/7/12 16:58
 * @Description :
 */

@RestController
@RequestMapping({"/wechat"})
public class LoginController {

    @Autowired
    private LoginFeign loginFeign;
    /*@PostMapping("loginenter")
    public String loginenter(XUserMsg XUserMsg){
      return loginService.xsxLogin(XUserMsg);
    }*/

   /* @PostMapping("javaShopLogin")
    public Result javaShopLogin(JUserMsg jUserMsg) {
        return Result.ok(loginService.javaShopLogin(jUserMsg));
    }*/

    @PostMapping("/loginenter")
    public String loginenter(UserInfoQueryVo userInfo, BindingResult result){
        JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(userInfo),JSONObject.class, Feature.OrderedField);
        return loginFeign.login(jsonObject,result);
    }
    //修改支付密码
    @PostMapping("/forgetpassword")
    public String forgetpassword(UserInfoVo userInfoVo, BindingResult result, HttpSession session){

        JSONObject jsonObject = JsonObjectUtil.ObjectToJson(userInfoVo);
        return loginFeign.forgetpassword(jsonObject,result,session);
    }

    @RequestMapping("/getrandomcode")
    public String getRandomCode(){
        return loginFeign.getRandomCode();
    }
}
